/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2019-2022.
 * Description: In the sub-card scenario of the router, the device needs to be
 * set hot-swapped during the startup process,then bus/memory resource is
 * reserved in advance.After the startup, the daughter card can allocate
 * resources normally when the daughter card is inserted.
 * Author: wangliang
 * Create: 2019-02-15
 */

#include <linux/kernel.h>
#include <linux/export.h>
#include <linux/pci.h>
#include <linux/fix-hisi.h>

#ifdef CONFIG_RTOS_FIX_HISI_HP_DEVICE
static fix_hisi_fn fix_hisi_hp_device;

int register_fix_hisi_hook(fix_hisi_fn fn)
{
	if (fn == NULL)
		return -EINVAL;
	if (fix_hisi_hp_device != NULL)
		return -EEXIST;
	fix_hisi_hp_device = fn;
	return 0;
}
EXPORT_SYMBOL_NS(register_fix_hisi_hook, HW_RTOS_NS);

void unregister_fix_hisi_hook(void)
{
	fix_hisi_hp_device = NULL;
}
EXPORT_SYMBOL_NS(unregister_fix_hisi_hook, HW_RTOS_NS);

/* quirk for some broken hisi chip */
static void quirk_fix_hisi_hp_device(struct pci_dev *dev)
{
	if (fix_hisi_hp_device != NULL)
		fix_hisi_hp_device(dev);
}
DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, quirk_fix_hisi_hp_device);
#endif
